<template>
  <div class="app-container">
    <div class="default-box">
      <div class="filter-container">
        <el-button class="filter-item" type="primary" icon="el-icon-plus" round>
          新增
        </el-button>
        <el-button class="filter-item" type="primary" icon="el-icon-notebook-2" round plain>
          日志
        </el-button>
      </div>
      <el-table
        :key="tableKey"
        v-loading="listLoading"
        :data="list"
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="名称" width="200" show-overflow-tooltip>
          <template>
            <span>高级</span>
          </template>
        </el-table-column>
        <el-table-column label="手续费" width="200">
          <template>
            <span>1000</span>
          </template>
        </el-table-column>
        <el-table-column label="等级" width="200">
          <template>
            <span>10</span>
          </template>
        </el-table-column>
        <el-table-column label="推广实名数" width="200">
          <template>
            <span>10000000</span>
          </template>
        </el-table-column>
        <el-table-column label="备忘" min-width="300" show-overflow-tooltip>
          <template>
            <span>不可到达，0手续费</span>
          </template>
        </el-table-column>
        <el-table-column label="状态" width="200">
          <template>
            <el-switch v-model="value1" active-text="禁用" inactive-text="启用" />
          </template>
        </el-table-column>
        <el-table-column label="更新时间" width="200">
          <template>
            <span>2022-05-01 00:00:00</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="150" class-name="small-padding fixed-width">
          <template>
            <i class="el-icon-edit" :style="{color:$store.state.settings.theme}" />
            <i class="el-icon-delete danger-color" />
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
  </div>
</template>

<script>
import { fetchList } from '@/api/article'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
export default {
  name: 'Adminrole',
  components: { Pagination },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      },
      value1: false
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    }
  }
}
</script>
<style scoped>
  [class^=el-icon-], [class*=" el-icon-"]{
    font-size: 16px;
  }
  .small-padding i{
    margin-right: 12px;
  }
  .small-padding i:last-child{
    margin-right: 0px;
  }
  ::v-deep .filter-container .el-input--medium .el-input__inner{
    width: 240px;
  }
</style>
